<html>
<script type="text/javascript">
var singleton = ()=>{
    var instance;
    var createInstance = ()=>{
        this.a = 1;
        this.b = 2;
    }
    return {
         getInstance:()=>{
            if(!instance){
               instance = createInstance();
           }
            return instance;
         }
     }
}
var test = singleton();

var result = test.getInstance();
var test2 = test.getInstance();
console.log(result == test2); //true
</script>
</html>